from flask import Flask
from App.settings import envs
from App.views import init_view

from App.ext import init_ext

from flask_cors import *


def create_app(env):
    app = Flask(__name__)
    
    app.config.from_object(envs.get(env))
    app.config['JSON_AS_ASCII'] = False
    init_ext(app)
    init_view(app=app)

    # 设置跨域
    CORS(app, supports_credentials=True)
    return app
